﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Windows;
using System.Windows.Data;
using Microsoft.Practices.Prism.Commands;
using ParaEditor.Common;
using ParaEditor.DAO;
using ParaEditor.DAO.ParaDAO;
using ParaEditor.Desktop.Interfaces;
using ParaEditor.Domain.Entities;
using ParaEditor.Infrastructure;

namespace ParaEditor.Desktop.ViewModel
{
    [Export(typeof(IPara4002ViewModel))]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class Para4002ViewModel : ViewModelBase, IPara4002ViewModel
    {
        private Para4002DAO paramDao;
        private Para4006DAO param4006Dao;
        private Para4004DAO param4004Dao;
        private Para4003DAO param4003Dao;

        private ICollectionView infoVerList;
        public ICollectionView InfoVerList
        {
            get
            {
                return infoVerList;
            }
            set
            {
                this.infoVerList = value;
                this.RaisePropertyChangedEvent("InfoVerList");
            }
        }

        private ICollectionView feiLv1;
        public ICollectionView QuYu1
        {
            get
            {
                return feiLv1;
            }
            set
            {
                this.feiLv1 = value;
                this.RaisePropertyChangedEvent("QuYu1");
            }
        }

        private ICollectionView feiLv2;
        public ICollectionView QuYu2
        {
            get
            {
                return feiLv2;
            }
            set
            {
                this.feiLv2 = value;
                this.RaisePropertyChangedEvent("QuYu2");
            }
        }

        private ICollectionView feiLv3;
        public ICollectionView QuYu3
        {
            get
            {
                return feiLv3;
            }
            set
            {
                this.feiLv3 = value;
                this.RaisePropertyChangedEvent("QuYu3");
            }
        }

        private ICollectionView feiGaoFeng1;
        public ICollectionView FeiGaoFeng1
        {
            get
            {
                return feiGaoFeng1;
            }
            set
            {
                this.feiGaoFeng1 = value;
                this.RaisePropertyChangedEvent("FeiGaoFeng1");
            }
        }

        private ICollectionView feiGaoFeng2;
        public ICollectionView FeiGaoFeng2
        {
            get
            {
                return feiGaoFeng2;
            }
            set
            {
                this.feiGaoFeng2 = value;
                this.RaisePropertyChangedEvent("FeiGaoFeng2");
            }
        }

        private ICollectionView feiGaoFeng3;
        public ICollectionView FeiGaoFeng3
        {
            get
            {
                return feiGaoFeng3;
            }
            set
            {
                this.feiGaoFeng3 = value;
                this.RaisePropertyChangedEvent("FeiGaoFeng3");
            }
        }

        private ICollectionView daZhe1;
        public ICollectionView DaZhe1
        {
            get
            {
                return daZhe1;
            }
            set
            {
                this.daZhe1 = value;
                this.RaisePropertyChangedEvent("DaZhe1");
            }
        }

        private bool isCheckedLJCZ;
        public bool IsCheckedLJCZ
        {
            get
            {
                return this.isCheckedLJCZ;
            }
            set
            {
                this.isCheckedLJCZ = value;
                if (this.isCheckedLJCZ)
                {
                    this.LJCZEnable = true;
                }
                else
                {
                    this.LJCZEnable = false;
                }
                this.RaisePropertyChangedEvent("IsCheckedLJCZ");
            }
        }

        private bool isCheckedLC;
        public bool IsCheckedLC
        {
            get
            {
                return this.isCheckedLC;
            }
            set
            {
                this.isCheckedLC = value;
                if (this.isCheckedLC)
                {
                    this.LCEnable = true;
                }
                else
                {
                    this.LCEnable = false;
                }
                this.RaisePropertyChangedEvent("IsCheckedLC");
            }
        }

        private ICollectionView daZhe2;
        public ICollectionView DaZhe2
        {
            get
            {
                return daZhe2;
            }
            set
            {
                this.daZhe2 = value;
                this.RaisePropertyChangedEvent("DaZhe2");
            }
        }

        private ICollectionView daZhe3;
        public ICollectionView DaZhe3
        {
            get
            {
                return daZhe3;
            }
            set
            {
                this.daZhe3 = value;
                this.RaisePropertyChangedEvent("DaZhe3");
            }
        }

        private ICollectionView quanJia1;
        public ICollectionView QuanJia1
        {
            get
            {
                return quanJia1;
            }
            set
            {
                this.quanJia1 = value;
                this.RaisePropertyChangedEvent("QuanJia1");
            }
        }

        private ICollectionView quanJia2;
        public ICollectionView QuanJia2
        {
            get
            {
                return quanJia2;
            }
            set
            {
                this.quanJia2 = value;
                this.RaisePropertyChangedEvent("QuanJia2");
            }
        }

        private ICollectionView quanJia3;
        public ICollectionView QuanJia3
        {
            get
            {
                return quanJia3;
            }
            set
            {
                this.quanJia3 = value;
                this.RaisePropertyChangedEvent("QuanJia3");
            }
        }

        private ICollectionView paraCollectionDetail;
        public ICollectionView ParaCollectionDetail
        {
            get
            {
                return this.paraCollectionDetail;
            }
            set
            {
                this.paraCollectionDetail = value;
                this.RaisePropertyChangedEvent("ParaCollectionDetail");
            }
        }

        private ICollectionView colorList;
        public ICollectionView ColorList
        {
            get
            {
                return colorList;
            }
            set
            {
                this.colorList = value;
                this.RaisePropertyChangedEvent("ColorList");
            }
        }

        private int lostFine;
        public int LostFine
        {
            get
            {
                return this.lostFine;
            }
            set
            {
                this.lostFine = value;
                this.RaisePropertyChangedEvent("LostFine");
            }
        }

        private int farFine;
        public int FarFine
        {
            get
            {
                return this.farFine;
            }
            set
            {
                this.farFine = value;
                this.RaisePropertyChangedEvent("FarFine");
            }
        }

        private int lateFine;
        public int LateFine
        {
            get
            {
                return this.lateFine;
            }
            set
            {
                this.lateFine = value;
                this.RaisePropertyChangedEvent("LateFine");
            }
        }

        private int ioAddonFine;
        public int IoAddonFine
        {
            get
            {
                return this.ioAddonFine;
            }
            set
            {
                this.ioAddonFine = value;
                this.RaisePropertyChangedEvent("IoAddonFine");
            }
        }

        private int initVal;
        public int InitVal
        {
            get
            {
                return this.initVal;
            }
            set
            {
                this.initVal = value;
                this.RaisePropertyChangedEvent("InitVal");
            }
        }


        private int initValue;
        public int InitValue
        {
            get
            {
                return this.initValue;
            }
            set
            {
                this.initValue = value;
                this.RaisePropertyChangedEvent("InitValue");
            }
        }

        private int sptcMaxAmount;
        public int SptcMaxAmount
        {
            get
            {
                return this.sptcMaxAmount;
            }
            set
            {
                this.sptcMaxAmount = value;
                this.RaisePropertyChangedEvent("SptcMaxAmount");
            }
        }

        private short tomorrowHour;
        public short TomorrowHour
        {
            get
            {
                return this.tomorrowHour;
            }
            set
            {
                this.tomorrowHour = value;
                this.RaisePropertyChangedEvent("TomorrowHour");
            }
        }

        private short spaceTime;
        public short SpaceTime
        {
            get
            {
                return this.spaceTime;
            }
            set
            {
                this.spaceTime = value;
                this.RaisePropertyChangedEvent("SpaceTime");
            }
        }

        private short longestPeriodArea1;
        public short LongestPeriodArea1
        {
            get
            {
                return this.longestPeriodArea1;
            }
            set
            {
                this.longestPeriodArea1 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea1");
            }
        }

        private short longestPeriodArea2;
        public short LongestPeriodArea2
        {
            get
            {
                return this.longestPeriodArea2;
            }
            set
            {
                this.longestPeriodArea2 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea2");
            }
        }

        private short longestPeriodArea3;
        public short LongestPeriodArea3
        {
            get
            {
                return this.longestPeriodArea3;
            }
            set
            {
                this.longestPeriodArea3 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea3");
            }
        }

        private short longestPeriodArea4;
        public short LongestPeriodArea4
        {
            get
            {
                return this.longestPeriodArea4;
            }
            set
            {
                this.longestPeriodArea4 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea4");
            }
        }

        private short longestPeriodArea5;
        public short LongestPeriodArea5
        {
            get
            {
                return this.longestPeriodArea5;
            }
            set
            {
                this.longestPeriodArea5 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea5");
            }
        }

        private short longestPeriodArea6;
        public short LongestPeriodArea6
        {
            get
            {
                return this.longestPeriodArea6;
            }
            set
            {
                this.longestPeriodArea6 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea6");
            }
        }

        private short longestPeriodArea7;
        public short LongestPeriodArea7
        {
            get
            {
                return this.longestPeriodArea7;
            }
            set
            {
                this.longestPeriodArea7 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea7");
            }
        }

        private short longestPeriodArea8;
        public short LongestPeriodArea8
        {
            get
            {
                return this.longestPeriodArea8;
            }
            set
            {
                this.longestPeriodArea8 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea8");
            }
        }

        private short longestPeriodArea9;
        public short LongestPeriodArea9
        {
            get
            {
                return this.longestPeriodArea9;
            }
            set
            {
                this.longestPeriodArea9 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea9");
            }
        }

        private short longestPeriodArea10;
        public short LongestPeriodArea10
        {
            get
            {
                return this.longestPeriodArea10;
            }
            set
            {
                this.longestPeriodArea10 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea10");
            }
        }

        private short longestPeriodArea11;
        public short LongestPeriodArea11
        {
            get
            {
                return this.longestPeriodArea11;
            }
            set
            {
                this.longestPeriodArea11 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea11");
            }
        }

        private short longestPeriodArea12;
        public short LongestPeriodArea12
        {
            get
            {
                return this.longestPeriodArea12;
            }
            set
            {
                this.longestPeriodArea12 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea12");
            }
        }

        private short longestPeriodArea13;
        public short LongestPeriodArea13
        {
            get
            {
                return this.longestPeriodArea13;
            }
            set
            {
                this.longestPeriodArea13 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea13");
            }
        }

        private short longestPeriodArea14;
        public short LongestPeriodArea14
        {
            get
            {
                return this.longestPeriodArea14;
            }
            set
            {
                this.longestPeriodArea14 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea14");
            }
        }

        private short longestPeriodArea15;
        public short LongestPeriodArea15
        {
            get
            {
                return this.longestPeriodArea15;
            }
            set
            {
                this.longestPeriodArea15 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea15");
            }
        }

        private short longestPeriodArea16;
        public short LongestPeriodArea16
        {
            get
            {
                return this.longestPeriodArea16;
            }
            set
            {
                this.longestPeriodArea16 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea16");
            }
        }

        private short longestPeriodArea17;
        public short LongestPeriodArea17
        {
            get
            {
                return this.longestPeriodArea17;
            }
            set
            {
                this.longestPeriodArea17 = value;
                this.RaisePropertyChangedEvent("LongestPeriodArea17");
            }
        }

        private short ticketType;
        public short TicketType
        {
            get
            {
                return this.ticketType;
            }
            set
            {
                this.ticketType = value;
                this.RaisePropertyChangedEvent("TicketType");
            }
        }

        private string nameCn;
        public string NameCn
        {
            get
            {
                return this.nameCn;
            }
            set
            {
                this.nameCn = value;
                this.RaisePropertyChangedEvent("NameCn");
            }
        }

        private string nameEn;
        public string NameEn
        {
            get
            {
                return this.nameEn;
            }
            set
            {
                this.nameEn = value;
                this.RaisePropertyChangedEvent("NameEn");
            }
        }

        private int keptValue;
        public int KeptValue
        {
            get
            {
                return this.keptValue;
            }
            set
            {
                this.keptValue = value;
                this.RaisePropertyChangedEvent("KeptValue");
            }
        }

        private short mostTimes;
        public short MostTimes
        {
            get
            {
                return this.mostTimes;
            }
            set
            {
                this.mostTimes = value;
                this.RaisePropertyChangedEvent("MostTimes");
            }
        }

        private int validPeriod;
        public int ValidPeriod
        {
            get
            {
                return this.validPeriod;
            }
            set
            {
                this.validPeriod = value;
                this.RaisePropertyChangedEvent("ValidPeriod");
            }
        }

        private int ioBpAmount;
        public int IoBpAmount
        {
            get
            {
                return this.ioBpAmount;
            }
            set
            {
                this.ioBpAmount = value;
                this.RaisePropertyChangedEvent("IoBpAmount");
            }
        }

        private bool reusalbe;
        public bool Reusable
        {
            get
            {
                return this.reusalbe;
            }
            set
            {
                this.reusalbe = value;
                this.RaisePropertyChangedEvent("Reusable");
            }
        }

        private bool lightOn;
        public bool LightOn
        {
            get
            {
                return this.lightOn;
            }
            set
            {
                this.lightOn = value;
                this.RaisePropertyChangedEvent("LightOn");
            }
        }

        private bool beepOn;
        public bool BeepOn
        {
            get
            {
                return this.beepOn;
            }
            set
            {
                this.beepOn = value;
                this.RaisePropertyChangedEvent("BeepOn");
            }
        }

        private bool verifyResv1;
        public bool VerifyResv1
        {
            get
            {
                return this.verifyResv1;
            }
            set
            {
                this.verifyResv1 = value;
                this.RaisePropertyChangedEvent("VerifyResv1");
            }
        }

        private bool verifyResv2;
        public bool VerifyResv2
        {
            get
            {
                return this.verifyResv2;
            }
            set
            {
                this.verifyResv2 = value;
                this.RaisePropertyChangedEvent("VerifyResv2");
            }
        }

        private bool ticketPriceAward;
        public bool TicketPriceAward
        {
            get
            {
                return this.ticketPriceAward;
            }
            set
            {
                this.ticketPriceAward = value;
                this.RaisePropertyChangedEvent("TicketPriceAward");
            }
        }

        private bool checkGiveStatn;
        public bool CheckGiveStatn
        {
            get
            {
                return this.checkGiveStatn;
            }
            set
            {
                this.checkGiveStatn = value;
                this.RaisePropertyChangedEvent("CheckGiveStatn");
            }
        }

        private bool accmAwardWayAmt;
        public bool AccmAwardWayAmt
        {
            get
            {
                return this.accmAwardWayAmt;
            }
            set
            {
                this.accmAwardWayAmt = value;
                this.RaisePropertyChangedEvent("AccmAwardWayAmt");
            }
        }

        private bool accmAwardWayTime;
        public bool AccmAwardWayTime
        {
            get
            {
                return this.accmAwardWayTime;
            }
            set
            {
                this.accmAwardWayTime = value;
                this.RaisePropertyChangedEvent("AccmAwardWayTime");
            }
        }

        private bool lastReward;
        public bool LastReward
        {
            get
            {
                return this.lastReward;
            }
            set
            {
                this.lastReward = value;
                this.RaisePropertyChangedEvent("LastReward");
            }
        }

        private decimal accmAwardStartTimes;
        public decimal AccmAwardStartTimes
        {
            get
            {
                return this.accmAwardStartTimes;
            }
            set
            {
                this.accmAwardStartTimes = value;
                this.RaisePropertyChangedEvent("AccmAwardStartTimes");
            }
        }

        private decimal accmAwardStartValue;
        public decimal AccmAwardStartValue
        {
            get
            {
                return this.accmAwardStartValue;
            }
            set
            {
                this.accmAwardStartValue = value;
                this.RaisePropertyChangedEvent("AccmAwardStartValue");
            }
        }

        private int accmAwardPercent;
        public int AccmAwardPercent
        {
            get
            {
                return this.accmAwardPercent;
            }
            set
            {
                this.accmAwardPercent = value;
                this.RaisePropertyChangedEvent("AccmAwardPercent");
            }
        }

        private int timeoutAmount;
        public int TimeoutAmount
        {
            get
            {
                return this.timeoutAmount;
            }
            set
            {
                this.timeoutAmount = value;
                this.RaisePropertyChangedEvent("TimeoutAmount");
            }
        }

        private short awardValidPeriod;
        public short AwardValidPeriod
        {
            get
            {
                return this.awardValidPeriod;
            }
            set
            {
                this.awardValidPeriod = value;
                this.RaisePropertyChangedEvent("AwardValidPeriod");
            }
        }

        private int firstComboRate;
        public int FirstComboRate
        {
            get
            {
                return this.firstComboRate;
            }
            set
            {
                this.firstComboRate = value;
                this.RaisePropertyChangedEvent("FirstComboRate");
            }
        }

        private int secondComboRate;
        public int SecondComboRate
        {
            get
            {
                return this.secondComboRate;
            }
            set
            {
                this.secondComboRate = value;
                this.RaisePropertyChangedEvent("SecondComboRate");
            }
        }

        private bool awardIndustryBus;
        public bool AwardIndustryBus
        {
            get
            {
                return this.awardIndustryBus;
            }
            set
            {
                this.awardIndustryBus = value;
                this.RaisePropertyChangedEvent("AwardIndustryBus");
            }
        }

        private bool awardIndustryShip;
        public bool AwardIndustryShip
        {
            get
            {
                return this.awardIndustryShip;
            }
            set
            {
                this.awardIndustryShip = value;
                this.RaisePropertyChangedEvent("AwardIndustryShip");
            }
        }

        private bool awardIndustryResv1;
        public bool AwardIndustryResv1
        {
            get
            {
                return this.awardIndustryResv1;
            }
            set
            {
                this.awardIndustryResv1 = value;
                this.RaisePropertyChangedEvent("AwardIndustryResv1");
            }
        }

        private bool awardPriority00;
        public bool AwardPriority00
        {
            get
            {
                return this.awardPriority00;
            }
            set
            {
                this.awardPriority00 = value;
                this.RaisePropertyChangedEvent("AwardPriority00");
            }
        }

        private bool awardPriority01;
        public bool AwardPriority01
        {
            get
            {
                return this.awardPriority01;
            }
            set
            {
                this.awardPriority01 = value;
                this.RaisePropertyChangedEvent("AwardPriority01");
            }
        }

        private bool awardPriority02;
        public bool AwardPriority02
        {
            get
            {
                return this.awardPriority02;
            }
            set
            {
                this.awardPriority02 = value;
                this.RaisePropertyChangedEvent("AwardPriority02");
            }
        }

        private bool awardPriority03;
        public bool AwardPriority03
        {
            get
            {
                return this.awardPriority03;
            }
            set
            {
                this.awardPriority03 = value;
                this.RaisePropertyChangedEvent("AwardPriority03");
            }
        }

        private bool awardPriority04;
        public bool AwardPriority04
        {
            get
            {
                return this.awardPriority04;
            }
            set
            {
                this.awardPriority04 = value;
                this.RaisePropertyChangedEvent("AwardPriority04");
            }
        }

        private bool awardPriority05;
        public bool AwardPriority05
        {
            get
            {
                return this.awardPriority05;
            }
            set
            {
                this.awardPriority05 = value;
                this.RaisePropertyChangedEvent("AwardPriority05");
            }
        }

        private short jsjcTimeUnit;
        public short JsjcTimeUnit
        {
            get
            {
                return this.jsjcTimeUnit;
            }
            set
            {
                this.jsjcTimeUnit = value;
                this.RaisePropertyChangedEvent("JsjcTimeUnit");
            }
        }

        private int sptcInitVal;
        public int SptcInitVal
        {
            get
            {
                return this.sptcInitVal;
            }
            set
            {
                this.sptcInitVal = value;
                this.RaisePropertyChangedEvent("SptcInitVal");
            }
        }

        private short tzTicketType;
        public short TzTicketType
        {
            get
            {
                return this.tzTicketType;
            }
            set
            {
                this.tzTicketType = value;
                this.RaisePropertyChangedEvent("TzTicketType");
            }
        }

        private int sptcInitAward;
        public int SptcInitAward
        {
            get
            {
                return this.sptcInitAward;
            }
            set
            {
                this.sptcInitAward = value;
                this.RaisePropertyChangedEvent("SptcInitAward");
            }
        }

        private int sptcFillSelection1;
        public int SptcFillSelection1
        {
            get
            {
                return this.sptcFillSelection1;
            }
            set
            {
                this.sptcFillSelection1 = value;
                this.RaisePropertyChangedEvent("SptcFillSelection1");
            }
        }

        private int sptcFillSelection2;
        public int SptcFillSelection2
        {
            get
            {
                return this.sptcFillSelection2;
            }
            set
            {
                this.sptcFillSelection2 = value;
                this.RaisePropertyChangedEvent("SptcFillSelection2");
            }
        }

        private int sptcFillSelection3;
        public int SptcFillSelection3
        {
            get
            {
                return this.sptcFillSelection3;
            }
            set
            {
                this.sptcFillSelection3 = value;
                this.RaisePropertyChangedEvent("SptcFillSelection3");
            }
        }

        private int sptcFillSelection4;
        public int SptcFillSelection4
        {
            get
            {
                return this.sptcFillSelection4;
            }
            set
            {
                this.sptcFillSelection4 = value;
                this.RaisePropertyChangedEvent("SptcFillSelection4");
            }
        }

        //SptcFillAward1
        private int sptcFillAward1;
        public int SptcFillAward1
        {
            get
            {
                return this.sptcFillAward1;
            }
            set
            {
                this.sptcFillAward1 = value;
                this.RaisePropertyChangedEvent("SptcFillAward1");
            }
        }

        private int sptcFillAward2;
        public int SptcFillAward2
        {
            get
            {
                return this.sptcFillAward2;
            }
            set
            {
                this.sptcFillAward2 = value;
                this.RaisePropertyChangedEvent("SptcFillAward2");
            }
        }

        private int sptcFillAward3;
        public int SptcFillAward3
        {
            get
            {
                return this.sptcFillAward3;
            }
            set
            {
                this.sptcFillAward3 = value;
                this.RaisePropertyChangedEvent("SptcFillAward3");
            }
        }

        private int sptcFillAward4;
        public int SptcFillAward4
        {
            get
            {
                return this.sptcFillAward4;
            }
            set
            {
                this.sptcFillAward4 = value;
                this.RaisePropertyChangedEvent("SptcFillAward4");
            }
        }

        private bool ctrlCanfill;
        public bool CtrlCanfill
        {
            get
            {
                return this.ctrlCanfill;
            }
            set
            {
                this.ctrlCanfill = value;
                this.RaisePropertyChangedEvent("CtrlCanfill");
            }
        }

        private bool ctrlReward;
        public bool CtrlReward
        {
            get
            {
                return this.ctrlReward;
            }
            set
            {
                this.ctrlReward = value;
                this.RaisePropertyChangedEvent("CtrlReward");
            }
        }

        private int transYx;
        public int TransYx
        {
            get
            {
                return this.transYx;
            }
            set
            {
                this.transYx = value;
                this.RaisePropertyChangedEvent("TransYx");
            }
        }

        //CtrlCansale 允许在BOM发售
        private bool ctrlCansale;
        public bool CtrlCansale
        {
            get
            {
                return this.ctrlCansale;
            }
            set
            {
                this.ctrlCansale = value;
                this.RaisePropertyChangedEvent("CtrlCansale");
            }
        }

        private bool ctrlResv5;
        public bool CtrlResv5
        {
            get
            {
                return this.ctrlResv5;
            }
            set
            {
                this.ctrlResv5 = value;
                this.RaisePropertyChangedEvent("CtrlResv5");
            }
        }

        private bool ctrlCanTouzhi;
        public bool CtrlCanTouzhi
        {
            get
            {
                return this.ctrlCanTouzhi;
            }
            set
            {
                this.ctrlCanTouzhi = value;
                this.RaisePropertyChangedEvent("CtrlCanTouzhi");
            }
        }

        private bool ctrlJSTP;
        public bool CtrlJSTP
        {
            get
            {
                return this.ctrlJSTP;
            }
            set
            {
                this.ctrlJSTP = value;
                this.RaisePropertyChangedEvent("CtrlJSTP");
            }
        }

        private int rateTimeLooseWorkday;
        public int RateTimeLooseWorkday
        {
            get
            {
                return this.rateTimeLooseWorkday;
            }
            set
            {
                this.rateTimeLooseWorkday = value;
                this.RaisePropertyChangedEvent("RateTimeLooseWorkday");
            }
        }

        private int rateTimeLooseWeekend;
        public int RateTimeLooseWeekend
        {
            get
            {
                return this.rateTimeLooseWeekend;
            }
            set
            {
                this.rateTimeLooseWeekend = value;
                this.RaisePropertyChangedEvent("RateTimeLooseWeekend");
            }
        }

        private int rateTimeLooseHoliday;
        public int RateTimeLooseHoliday
        {
            get
            {
                return this.rateTimeLooseHoliday;
            }
            set
            {
                this.rateTimeLooseHoliday = value;
                this.RaisePropertyChangedEvent("RateTimeLooseHoliday");
            }
        }

        private short jSTKXE;
        public short JSTKXE
        {
            get
            {
                return this.jSTKXE;
            }
            set
            {
                this.jSTKXE = value;
                this.RaisePropertyChangedEvent("JSTKXE");
            }
        }

        private Visibility editGroupBoxVisible;
        public Visibility EditGroupBoxVisible
        {
            get
            {
                return this.editGroupBoxVisible;
            }
            set
            {
                this.editGroupBoxVisible = value;
                this.RaisePropertyChangedEvent("EditGroupBoxVisible");
            }
        }

        private bool verifyResv2_BiLi;
        public bool VerifyResv2_BiLi
        {
            get
            {
                return this.verifyResv2_BiLi;
            }
            set
            {
                this.verifyResv2_BiLi = value;
                this.RaisePropertyChangedEvent("VerifyResv2_BiLi");
            }
        }

        private bool verifyResv2_DingZhi;
        public bool VerifyResv2_DingZhi
        {
            get
            {
                return this.verifyResv2_DingZhi;
            }
            set
            {
                this.verifyResv2_DingZhi = value;
                this.RaisePropertyChangedEvent("VerifyResv2_DingZhi");
            }
        }

        private bool lJCZEnable;
        public bool LJCZEnable
        {
            get
            {
                return this.lJCZEnable;
            }
            set
            {
                this.lJCZEnable = value;
                this.RaisePropertyChangedEvent("LJCZEnable");
            }
        }

        private bool lCEnable;
        public bool LCEnable
        {
            get
            {
                return this.lCEnable;
            }
            set
            {
                this.lCEnable = value;
                this.RaisePropertyChangedEvent("LCEnable");
            }
        }

        private int mostTimesMonth;
        public int MostTimesMonth
        {
            get
            {
                return this.mostTimesMonth;
            }
            set
            {
                this.mostTimesMonth = value;
                this.RaisePropertyChangedEvent("MostTimesMonth");
            }
        }

        private short holiDayAreaInfo;
        public short HoliDayAreaInfo
        {
            get
            {
                return this.holiDayAreaInfo;
            }
            set
            {
                this.holiDayAreaInfo = value;
                this.RaisePropertyChangedEvent("HoliDayAreaInfo");
            }
        }

        private short workDayAreaInfo;
        public short WorkDayAreaInfo
        {
            get
            {
                return this.workDayAreaInfo;
            }
            set
            {
                this.workDayAreaInfo = value;
                this.RaisePropertyChangedEvent("WorkDayAreaInfo");
            }
        }

        private short weekEndAreaInfo;
        public short WeekEndAreaInfo
        {
            get
            {
                return this.weekEndAreaInfo;
            }
            set
            {
                this.weekEndAreaInfo = value;
                this.RaisePropertyChangedEvent("WeekEndAreaInfo");
            }
        }

        private short feiGaoFeng1RecordID;
        public short FeiGaoFeng1RecordID
        {
            get
            {
                return this.feiGaoFeng1RecordID;
            }
            set
            {
                this.feiGaoFeng1RecordID = value;
                this.RaisePropertyChangedEvent("FeiGaoFeng1RecordID");
            }
        }

        private short feiGaoFeng2RecordID;
        public short FeiGaoFeng2RecordID
        {
            get
            {
                return this.feiGaoFeng2RecordID;
            }
            set
            {
                this.feiGaoFeng2RecordID = value;
                this.RaisePropertyChangedEvent("FeiGaoFeng2RecordID");
            }
        }

        private short feiGaoFeng3RecordID;
        public short FeiGaoFeng3RecordID
        {
            get
            {
                return this.feiGaoFeng3RecordID;
            }
            set
            {
                this.feiGaoFeng3RecordID = value;
                this.RaisePropertyChangedEvent("FeiGaoFeng3RecordID");
            }
        }

        private short daZhe1RecordID;
        public short DaZhe1RecordID
        {
            get
            {
                return this.daZhe1RecordID;
            }
            set
            {
                this.daZhe1RecordID = value;
                this.RaisePropertyChangedEvent("DaZhe1RecordID");
            }
        }

        private short daZhe2RecordID;
        public short DaZhe2RecordID
        {
            get
            {
                return this.daZhe2RecordID;
            }
            set
            {
                this.daZhe2RecordID = value;
                this.RaisePropertyChangedEvent("DaZhe2RecordID");
            }
        }

        private short daZhe3RecordID;
        public short DaZhe3RecordID
        {
            get
            {
                return this.daZhe3RecordID;
            }
            set
            {
                this.daZhe3RecordID = value;
                this.RaisePropertyChangedEvent("DaZhe3RecordID");
            }
        }



        private short quanJia1RecordID;
        public short QuanJia1RecordID
        {
            get
            {
                return this.quanJia1RecordID;
            }
            set
            {
                this.quanJia1RecordID = value;
                this.RaisePropertyChangedEvent("QuanJia1RecordID");
            }
        }

        private short quanJia2RecordID;
        public short QuanJia2RecordID
        {
            get
            {
                return this.quanJia2RecordID;
            }
            set
            {
                this.quanJia2RecordID = value;
                this.RaisePropertyChangedEvent("QuanJia2RecordID");
            }
        }

        private short quanJia3RecordID;
        public short QuanJia3RecordID
        {
            get
            {
                return this.quanJia3RecordID;
            }
            set
            {
                this.quanJia3RecordID = value;
                this.RaisePropertyChangedEvent("QuanJia3RecordID");
            }
        }

        //Button
        public DelegateCommand AddParamCommand { get; private set; }
        public DelegateCommand DelParamCommand { get; private set; }
        public DelegateCommand SaveParamCommand { get; private set; }
        public DelegateCommand CanclEditParamCommand { get; private set; }
        public DelegateCommand NewVersionCommand { get; private set; }
        public DelegateCommand CopyCurrentVersionCommand { get; private set; }

        [ImportingConstructor]
        public Para4002ViewModel()
        {
            paramDao = new Para4002DAO();
            param4003Dao = new Para4003DAO();
            param4004Dao = new Para4004DAO();
            param4006Dao = new Para4006DAO();
            InfoVerList = CollectionViewSource.GetDefaultView(paramDao.GetAllVersion());
            if (paramDao.GetAllVersion().Count == 0)
            {
                Microsoft.Windows.Controls.MessageBox.Show("当前参数无任何参数版本");
            }
            InfoVerList.CurrentChanged += InfoVerList_CurrentChanged;

            ObservableCollection<Para4004> QuYuIndex = param4004Dao.GetParam4004();
            Para4004 param = new Para4004();
            Para4004Pk paramPk = new Para4004Pk();
            paramPk.infoVer = 1;
            paramPk.areaId = 255;
            param.para4004Pk = paramPk;
            param.areaInfo = 255;
            QuYu1 = CollectionViewSource.GetDefaultView(new ObservableCollection<Para4004>(QuYuIndex));
            QuYu2 = CollectionViewSource.GetDefaultView(new ObservableCollection<Para4004>(QuYuIndex));
            QuYu3 = CollectionViewSource.GetDefaultView(new ObservableCollection<Para4004>(QuYuIndex));

            ObservableCollection<Record> FeiGaoFengIndex = param4004Dao.GetLastestFeiGaoFengRecordID();
            Record defualtRecord = new Record();
            defualtRecord.RecordID = 255;
            FeiGaoFengIndex.Add(defualtRecord);
            FeiGaoFeng1 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(FeiGaoFengIndex));
            FeiGaoFeng2 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(FeiGaoFengIndex));
            FeiGaoFeng3 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(FeiGaoFengIndex));

            ObservableCollection<Record> DaZheIndex = param4003Dao.GetLastestDaZheRecordID();
            DaZhe1 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(DaZheIndex));
            DaZhe2 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(DaZheIndex));
            DaZhe3 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(DaZheIndex));

            ObservableCollection<Record> QuanJiaIndex = param4003Dao.GetLastestDaZheRecordID();
            QuanJia1 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(QuanJiaIndex));
            QuanJia2 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(QuanJiaIndex));
            QuanJia3 = CollectionViewSource.GetDefaultView(new ObservableCollection<Record>(QuanJiaIndex));

            ColorList = CollectionViewSource.GetDefaultView(new ObservableCollection<ColorDefine>(SetColorDefine()));

            //Button
            this.AddParamCommand = new DelegateCommand(this.AddParam);
            this.DelParamCommand = new DelegateCommand(this.DelParam);
            this.SaveParamCommand = new DelegateCommand(this.SaveParam);
            this.CanclEditParamCommand = new DelegateCommand(this.CanclEditParam);
            this.NewVersionCommand = new DelegateCommand(this.NewVersion);
            this.CopyCurrentVersionCommand = new DelegateCommand(this.CopyCurrentVersion);
        }

        private void NewVersion()
        {
            ObservableCollection<int> infoVerCollection = new ObservableCollection<int>();
            infoVerCollection = paramDao.GetAllVersion();
            int newVersion = paramDao.GetMaxID() + 1;
            infoVerCollection.Add(newVersion);
            InfoVerList = CollectionViewSource.GetDefaultView(infoVerCollection);
            InfoVerList.CurrentChanged += InfoVerList_CurrentChanged;
        }

        private void CopyCurrentVersion()
        {
            //查询当前版本
            ObservableCollection<Para4002> currentVersionParam = new ObservableCollection<Para4002>();
            int infoVer = (int)InfoVerList.CurrentItem;
            currentVersionParam = paramDao.GetObjectByInfoVer(infoVer);

            if (currentVersionParam.Count != 0)
            {
                Para4002 param = null;
                Para4002Pk paramPk = null;
                int newVersion = paramDao.GetMaxID() + 1;
                foreach (Para4002 item in currentVersionParam)
                {
                    param = new Para4002(item);
                    paramPk = new Para4002Pk();
                    //编辑参数
                    paramPk.infoVer = Int16.Parse(newVersion.ToString());
                    paramPk.ticketType = item.para4002Pk.ticketType;

                    param.para4002Pk = paramPk;

                    ResultValue result = paramDao.CreateObject(param);
                    if (result.Code != 0)
                    {
                        Microsoft.Windows.Controls.MessageBox.Show("复制过程中出现错误!错误信息：" + result.Msg);
                    }
                }
                //刷新
                ParaCollectionDetail = CollectionViewSource.GetDefaultView(paramDao.GetObjectByInfoVer(newVersion));
                InfoVerList = CollectionViewSource.GetDefaultView(paramDao.GetAllVersion());
                InfoVerList.CurrentChanged += InfoVerList_CurrentChanged;
            }
            else
            {
                Microsoft.Windows.Controls.MessageBox.Show("所查询的当前版本没有数据,不可进行复制");
            }
        }

        private void AddParam()
        {
            EditGroupBoxVisible = Visibility.Visible;
        }

        private void DelParam()
        {
            try
            {
                if (ParaCollectionDetail.CurrentItem != null)
                {
                    Para4002 param = ParaCollectionDetail.CurrentItem as Para4002;
                    if (Microsoft.Windows.Controls.MessageBox.Show("确认删除所选择的参数！", "4002参数", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question) == System.Windows.MessageBoxResult.OK)
                    {
                        //删除
                        ResultValue result = paramDao.DeleteObject(param,param.para4002Pk.infoVer);
                        if (result.Code == 0)
                        {
                            Microsoft.Windows.Controls.MessageBox.Show("删除成功");
                            //刷新
                            InfoVerList = CollectionViewSource.GetDefaultView(paramDao.GetAllVersion());
                            InfoVerList.CurrentChanged += InfoVerList_CurrentChanged;

                            ReflashDataGrid();

                        }
                        else
                        {
                            Microsoft.Windows.Controls.MessageBox.Show("删除失败!发生错误：" + result.Msg);
                        }
                    }
                }
                else
                {
                    Microsoft.Windows.Controls.MessageBox.Show("未选择要删除的参数");
                }
            }
            catch (Exception e)
            {
            }
        }

        public void SaveParam()
        {
            if (Confirm())
            {
                Para4002 param = new Para4002();
                Para4002Pk paramPk = new Para4002Pk();
                int tmp = (int)InfoVerList.CurrentItem;
                paramPk.infoVer = Int16.Parse(tmp.ToString());
                paramPk.ticketType = this.TicketType;
                param.para4002Pk = paramPk;
                //param.tid = this.Tid;
                //param.resv1 = this.Resv1;
                //param.resv2 = this.Resv2;

                //查当前所有记录
                int infoVer = (int)InfoVerList.CurrentItem;
                ObservableCollection<Para4002> p4002Collection = paramDao.GetObjectByInfoVer(infoVer);
                foreach (Para4002 obj in p4002Collection)
                {
                    obj.lostFine = this.LostFine;
                    obj.farFine = this.FarFine;
                    obj.lateFine = this.LateFine;
                    obj.ioAddonFine = this.IoAddonFine;
                    obj.initVal = this.InitVal;
                    obj.tomorrowHour = this.TomorrowHour;
                    obj.spaceTime = this.SpaceTime;
                    obj.longestPeriodArea1 = this.LongestPeriodArea1;
                    obj.longestPeriodArea2 = this.LongestPeriodArea2;
                    obj.longestPeriodArea3 = this.LongestPeriodArea3;
                    obj.longestPeriodArea4 = this.LongestPeriodArea4;
                    obj.longestPeriodArea5 = this.LongestPeriodArea5;
                    obj.longestPeriodArea6 = this.LongestPeriodArea6;
                    obj.longestPeriodArea7 = this.LongestPeriodArea7;
                    obj.longestPeriodArea8 = this.LongestPeriodArea8;
                    obj.longestPeriodArea9 = this.LongestPeriodArea9;
                    obj.longestPeriodArea10 = this.LongestPeriodArea10;
                    obj.longestPeriodArea11 = this.LongestPeriodArea11;
                    obj.longestPeriodArea12 = this.LongestPeriodArea12;
                    obj.longestPeriodArea13 = this.LongestPeriodArea13;
                    obj.longestPeriodArea14 = this.LongestPeriodArea14;
                    obj.longestPeriodArea15 = this.LongestPeriodArea15;
                    obj.longestPeriodArea16 = this.LongestPeriodArea16;
                    obj.longestPeriodArea17 = this.LongestPeriodArea17;
                    paramDao.UpdateTicketTypeInfo(obj);

                }

                param.lostFine = this.LostFine;
                param.farFine = this.FarFine;
                param.lateFine = this.LateFine;
                param.ioAddonFine = this.IoAddonFine;
                param.initVal = this.InitVal;
                param.tomorrowHour = this.TomorrowHour;
                param.spaceTime = this.SpaceTime;
                param.longestPeriodArea1 = this.LongestPeriodArea1;
                param.longestPeriodArea2 = this.LongestPeriodArea2;
                param.longestPeriodArea3 = this.LongestPeriodArea3;
                param.longestPeriodArea4 = this.LongestPeriodArea4;
                param.longestPeriodArea5 = this.LongestPeriodArea5;
                param.longestPeriodArea6 = this.LongestPeriodArea6;
                param.longestPeriodArea7 = this.LongestPeriodArea7;
                param.longestPeriodArea8 = this.LongestPeriodArea8;
                param.longestPeriodArea9 = this.LongestPeriodArea9;
                param.longestPeriodArea10 = this.LongestPeriodArea10;
                param.longestPeriodArea11 = this.LongestPeriodArea11;
                param.longestPeriodArea12 = this.LongestPeriodArea12;
                param.longestPeriodArea13 = this.LongestPeriodArea13;
                param.longestPeriodArea14 = this.LongestPeriodArea14;
                param.longestPeriodArea15 = this.LongestPeriodArea15;
                param.longestPeriodArea16 = this.LongestPeriodArea16;
                param.longestPeriodArea17 = this.LongestPeriodArea17;
                


                param.jstkxe = this.JSTKXE;
                param.nameEn = this.NameEn.Trim();
                param.nameCn = this.NameCn.Trim();

                param.nameCnPointer = 0;
                /*
                point = paramDao.GetPointByCnName(this.NameCn.Trim());
                if (point > 0)
                {
                    param.nameCnPointer = point;
                }
                else
                {
                    Microsoft.Windows.Controls.MessageBox.Show("保存失败！未找到此车站名相应的指针，检查此车站名是否正确，或是否存在于3011中!");
                    return;
                }
                 */
                //param.ctrlResv1 = this.CtrlResv1;
                //param.ctrlResv2 = this.CtrlResv2;
                //param.ctrlResv3 = this.CtrlResv3;
                //param.ctrlResv4 = this.CtrlResv4;
                if (this.CtrlCansale)
                {
                    param.ctrlCansale = 1;
                }
                else
                {
                    param.ctrlCansale = 0;
                }

                if (this.CtrlCanTouzhi)//0是允许透支 1是不允许透支
                {
                    param.ctrlCantouzhi = 1;
                }
                else
                {
                    param.ctrlCantouzhi = 0;
                }

                if (this.CtrlJSTP)
                {
                    param.ctrlJSTP = 1;
                }
                else
                {
                    param.ctrlJSTP = 0;
                }

                if (this.CtrlCanfill)
                {
                    param.ctrlCanfill = 1;
                }
                else
                {
                    param.ctrlCanfill = 0;
                }

                if (this.CtrlCansale)
                {
                    param.ctrlCansale = 1;
                }
                else
                {
                    param.ctrlCansale = 0;
                }

                if (this.CtrlResv5)
                {
                    param.ctrlResv5 = 1;
                }
                else
                {
                    param.ctrlResv5 = 0;
                }
                if (this.CtrlReward)
                {
                    param.ctrlReward = 1;
                }
                else
                {
                    param.ctrlReward = 0;
                }
                //param.ctrlNotdef = this.CtrlNotdef;
                if (this.TicketPriceAward)
                {
                    param.ticketPriceAward = 1;
                }
                else
                {
                    param.ticketPriceAward = 0;
                }

                if (this.VerifyResv1)
                {
                    param.verifyResv1 = 1;
                }
                else
                {
                    param.verifyResv1 = 0;
                }

                
                if (this.IsCheckedLJCZ)
                {
                    param.accmTakeAward = 1;//允许累计乘坐优惠
                    if (this.AccmAwardWayTime)
                    {
                        param.accmAwardWay = 0;
                    }
                    else if (this.AccmAwardWayAmt)
                    {
                        param.accmAwardWay = 1;
                    }
                }
                else
                {
                    param.accmTakeAward = 0;
                    param.accmAwardWay = 0;
                }

                if (this.IsCheckedLC)
                {
                    param.comboAward = 1;//允许联乘优惠
                    if (this.VerifyResv2_BiLi)
                    {
                        param.verifyResv2 = 0;
                    }
                    else if (this.VerifyResv2_DingZhi)
                    {
                        param.verifyResv2 = 1;
                    }
                }
                else
                {
                    param.comboAward = 0;
                    param.verifyResv2 = 0;
                }
                
                //param.verifyResv3 = this.VerifyResv3;
                //param.verifyResv4 = this.VerifyResv4;
                if (this.LastReward)
                {
                    param.lastReward = 1;
                }
                else
                {
                    param.lastReward = 0;
                }

                if (this.CheckGiveStatn)
                {
                    param.checkGiveStatn = 1;
                }
                else
                {
                    param.checkGiveStatn = 0;
                }

                if (this.Reusable)
                {
                    param.reusable = 1;
                }
                else
                {
                    param.reusable = 0;
                }

                if (this.LightOn)
                {
                    param.lightOn = 1;
                }
                else
                {
                    param.lightOn = 0;
                }

                if (this.BeepOn)
                {
                    param.beepOn = 1;
                }
                else
                {
                    param.beepOn = 0;
                }
                //param.verifyResv5 = this.VerifyResv5;
                //param.verifyResv6 = this.VerifyResv6;
                //param.verifyNotdef = this.VerifyNotdef;
                param.validPeriod = this.ValidPeriod;
                //param.specialVerify = this.SpecialVerify;
                param.initValue = this.InitValue;
                param.keptValue = this.KeptValue;
                param.sptcInitVal = this.SptcInitVal;
                param.sptcInitAward = this.SptcInitAward;
                param.sptcFillSelection1 = this.SptcFillSelection1;
                param.sptcFillSelection2 = this.SptcFillSelection2;
                param.sptcFillSelection3 = this.SptcFillSelection3;
                param.sptcFillSelection4 = this.SptcFillSelection4;
                param.sptcFillAward1 = this.SptcFillAward1;
                param.sptcFillAward2 = this.SptcFillAward2;
                param.sptcFillAward3 = this.SptcFillAward3;
                param.sptcFillAward4 = this.SptcFillAward4;
                param.rateTimeLooseWorkday = this.RateTimeLooseWorkday;

                param.rateTimeNonbusyWorkday = (FeiGaoFeng1.CurrentItem as Record).RecordID;
                if (DaZhe1.CurrentItem != null)
                {
                    param.rateTimeOffNonbusyWorkday = (DaZhe1.CurrentItem as Record).RecordID;
                }
                else
                {
                    MessageBox.Show("打折费率未选择");
                    return;
                }

                if (QuanJia1.CurrentItem != null)
                {
                    param.rateTimeFullBusyWorkday = (QuanJia1.CurrentItem as Record).RecordID;
                }
                else
                {
                    MessageBox.Show("全价费率码未选择");
                    return;
                }

                if (ColorList.CurrentItem != null)
                { 
                }
                
                param.rateTimeLooseWeekend = this.RateTimeLooseWeekend;
                
                param.rateTimeNonbusyWeekend = (FeiGaoFeng2.CurrentItem as Record).RecordID;
                if (DaZhe2.CurrentItem != null)
                {
                    param.rateTimeOffNonbusyWeekend = (DaZhe2.CurrentItem as Record).RecordID;
                }
                else
                {
                    MessageBox.Show("打折费率未选择");
                    return;
                }

                if (QuanJia2.CurrentItem != null)
                {
                    param.rateTimeFullBusyWeekend = (QuanJia2.CurrentItem as Record).RecordID;
                }
                else
                {
                    MessageBox.Show("全价费率码未选择");
                    return;
                }
                
                param.rateTimeLooseHoliday = this.RateTimeLooseHoliday;
                
                param.rateTimeNonbusyHoliday = (FeiGaoFeng3.CurrentItem as Record).RecordID;
                if (DaZhe2.CurrentItem != null)
                {
                    param.rateTimeOffNonbusyHoliday = (DaZhe3.CurrentItem as Record).RecordID;
                }
                else
                {
                    MessageBox.Show("打折费率未选择");
                    return;
                }
                if (QuanJia3.CurrentItem != null)
                {
                    param.rateTimeFullBusyHoliday = (QuanJia3.CurrentItem as Record).RecordID;
                }
                else
                {
                    MessageBox.Show("全价费率码未选择");
                    return;
                }
                

                param.areaInfoWorkDay = (QuYu1.CurrentItem as Para4004).areaInfo;
                param.areaInfoWeekEnd = (QuYu2.CurrentItem as Para4004).areaInfo;
                param.areaInfoHoliDay = (QuYu3.CurrentItem as Para4004).areaInfo;

                //param.rateTimeLooseNotdef = this.RateTimeLooseNotdef;
                //param.rateTimeNonbusyNotdef = this.RateTimeNonbusyNotdef;
                //param.rateTimeOffNonbusyNotdef = this.RateTimeOffNonbusyNotdef;
                //param.rateTimeFullBusyNotdef = this.RateTimeFullBusyNotdef;
                param.accmAwardStartTimes = this.AccmAwardStartTimes;
                param.accmAwardStartValue = this.AccmAwardStartValue;
                param.accmAwardPercent = this.AccmAwardPercent;
                param.firstComboRate = this.FirstComboRate;
                param.secondComboRate = this.SecondComboRate;

                if (AwardPriority00)
                {
                    param.awardPriority = 0;
                }
                if (AwardPriority01)
                {
                    param.awardPriority = 1;
                }
                if (AwardPriority02)
                {
                    param.awardPriority = 2;
                }
                if (AwardPriority03)
                {
                    param.awardPriority = 3;
                }
                if (AwardPriority04)
                {
                    param.awardPriority = 4;
                }
                if (AwardPriority05)
                {
                    param.awardPriority = 5;
                }
                param.awardValidPeriod = this.AwardValidPeriod;
                if (this.AwardIndustryBus)
                {
                    param.awardIndustryBus = 1;
                }
                else
                {
                    param.awardIndustryBus = 0;
                }

                if (this.AwardIndustryShip)
                {
                    param.awardIndustryShip = 1;
                }
                else
                {
                    param.awardIndustryShip = 0;
                }

                if (this.AwardIndustryResv1)
                {
                    param.awardIndustryResv1 = 1;
                }
                else
                {
                    param.awardIndustryResv1 = 0;
                }
                //param.awardIndustryResv2 = this.AwardIndustryResv2;
                //param.awardIndustryResv3 = this.AwardIndustryResv3;
                //param.awardIndustryResv4 = this.AwardIndustryResv4;
                //param.awardIndustryResv5 = this.AwardIndustryResv5;
                //param.awardIndustryResv6 = this.AwardIndustryResv6;
                //param.resv3 = this.Resv3;
                //param.resvBlock1 = this.ResvBlock1;
                //param.resvBlock2 = this.ResvBlock2;
                //param.resvBlock3 = this.ResvBlock3;
                //param.resvBlock4 = this.ResvBlock4;
                //param.resvbyte1 = this.Resvbyte1;
                //param.resvbyte2 = this.Resvbyte2;
                //param.resvbyte3 = this.Resvbyte3;
                param.mostTimesMonth = Int16.Parse(this.MostTimesMonth.ToString());
                param.mostTimes = this.MostTimes;
                //param.resv4 = this.Resv4;
                
                param.tzTicketType = this.TzTicketType;
                param.jsjcTimeUnit = this.JsjcTimeUnit;
                param.timeoutAmount = this.TimeoutAmount;
                param.ioBpAmout = this.IoBpAmount;
                //param.resvBlock21 = this.ResvBlock21;
                //param.resvBlock22 = this.ResvBlock22;
                //param.resvBlock23 = this.ResvBlock23;
                param.transYx = (short)this.TransYx;
                //param.cpuQyFlag = this.CpuQyFlag;
                param.sptcMaxAmount = this.SptcMaxAmount;
                //编辑参数
                ResultValue result = paramDao.CreateObject(param);
                if (result.Code == 0)
                {
                    Microsoft.Windows.Controls.MessageBox.Show("保存成功");
                    ReflashDataGrid();

                    CanclEditParam();
                }
                else
                {
                    Microsoft.Windows.Controls.MessageBox.Show("保存失败！发生错误:" + result.Msg);
                }
            }
        }

        private void CanclEditParam()
        {
            this.EditGroupBoxVisible = Visibility.Hidden;
            //将控件置为空
        }

        private bool Confirm()
        {
            bool flag = true;
            /*
            if (this.LineID != null && !"".Equals(this.LineID) && this.LineNmCn != null && !"".Equals(this.LineNmCn) && !"".Equals(this.LineNmEn) && this.LineNmEn != null)
            {
                flag = true;
            }
            else
            {
                Microsoft.Windows.Controls.MessageBox.Show("所填信息不完整");
                flag = false;
            }
             */
            return flag;
        }

        void InfoVerList_CurrentChanged(object sender, System.EventArgs ep)
        {
            if (InfoVerList.CurrentItem != null)
            {
                ReflashDataGrid();
            }
        }

        private void ReflashDataGrid()
        {
            int infoVer = (int)InfoVerList.CurrentItem;
            ParaCollectionDetail = CollectionViewSource.GetDefaultView(paramDao.GetObjectByInfoVer(infoVer));
            ParaCollectionDetail.CurrentChanged += ParaCollectionDetail_CurrentChanged;
        }

        void ParaCollectionDetail_CurrentChanged(object sender, System.EventArgs ep)
        {
            if(ParaCollectionDetail.CurrentItem != null)
            {
                Para4002 param = ParaCollectionDetail.CurrentItem as Para4002;
                //金额相关设置
                this.TimeoutAmount = param.timeoutAmount;
                this.LostFine = param.lostFine;
                this.FarFine = param.farFine;
                this.LateFine = param.lateFine;
                this.IoAddonFine = param.ioAddonFine;
                this.InitVal = param.initVal;
                //车站联乘时间间隔
                this.SpaceTime = param.spaceTime;
                //次日车票有效时间
                this.TomorrowHour = param.tomorrowHour;
                this.SptcMaxAmount = param.sptcMaxAmount;
                this.AccmAwardStartTimes = param.accmAwardStartTimes;
                this.AccmAwardStartValue = param.accmAwardStartValue;
                this.AccmAwardPercent = param.accmAwardPercent;
                this.AwardValidPeriod = param.awardValidPeriod;
                this.FirstComboRate = param.firstComboRate;
                this.SecondComboRate = param.secondComboRate;

                this.JsjcTimeUnit = param.jsjcTimeUnit;
                this.SptcInitVal = param.sptcInitVal;
                this.TzTicketType = param.tzTicketType;
                this.SptcInitAward = param.sptcInitAward;

                this.SptcFillSelection1 = param.sptcFillSelection1;
                this.SptcFillSelection2 = param.sptcFillSelection2;
                this.SptcFillSelection3 = param.sptcFillSelection3;
                this.SptcFillSelection4 = param.sptcFillSelection4;

                this.SptcFillAward1 = param.sptcFillAward1;
                this.SptcFillAward2 = param.sptcFillAward2;
                this.SptcFillAward3 = param.sptcFillAward3;
                this.SptcFillAward4 = param.sptcFillAward4;
                this.JSTKXE = param.jstkxe;

                this.RateTimeLooseWorkday = param.rateTimeLooseWorkday;
                this.RateTimeLooseWeekend = param.rateTimeLooseWeekend;
                this.RateTimeLooseHoliday = param.rateTimeLooseHoliday;

                //进站到出站允许的最长时间
                this.LongestPeriodArea1 = param.longestPeriodArea1;
                this.LongestPeriodArea2 = param.longestPeriodArea2;
                this.LongestPeriodArea3 = param.longestPeriodArea3;
                this.LongestPeriodArea4 = param.longestPeriodArea4;
                this.LongestPeriodArea5 = param.longestPeriodArea5;
                this.LongestPeriodArea6 = param.longestPeriodArea6;
                this.LongestPeriodArea7 = param.longestPeriodArea7;
                this.LongestPeriodArea8 = param.longestPeriodArea8;
                this.LongestPeriodArea9 = param.longestPeriodArea9;
                this.LongestPeriodArea10 = param.longestPeriodArea10;
                this.LongestPeriodArea11 = param.longestPeriodArea11;
                this.LongestPeriodArea12 = param.longestPeriodArea12;
                this.LongestPeriodArea13 = param.longestPeriodArea13;
                this.LongestPeriodArea14 = param.longestPeriodArea14;
                this.LongestPeriodArea15 = param.longestPeriodArea15;
                this.LongestPeriodArea16 = param.longestPeriodArea16;
                this.LongestPeriodArea17 = param.longestPeriodArea17;
                this.TransYx = param.transYx;
                //车票类型定义
                this.TicketType = param.para4002Pk.ticketType;
                this.NameCn = param.nameCn;
                this.NameEn = param.nameEn;
                this.KeptValue = param.keptValue;
                this.MostTimes = param.mostTimes;
                this.MostTimesMonth = param.mostTimesMonth;
                this.ValidPeriod = param.validPeriod;
                this.IoBpAmount = param.ioBpAmout;
                this.InitValue = param.initValue;

                //区域表 ComboBox绑定
                this.WorkDayAreaInfo = param.areaInfoWorkDay;
                this.WeekEndAreaInfo = param.areaInfoWeekEnd;
                this.HoliDayAreaInfo = param.areaInfoHoliDay;

                // 非高峰时段码
                this.FeiGaoFeng1RecordID = param.rateTimeNonbusyWorkday;
                this.FeiGaoFeng2RecordID = param.rateTimeNonbusyWeekend;
                this.FeiGaoFeng3RecordID = param.rateTimeNonbusyHoliday;

                //打折费率码
                this.DaZhe1RecordID = param.rateTimeOffNonbusyWorkday;
                this.DaZhe2RecordID = param.rateTimeOffNonbusyWeekend;
                this.DaZhe3RecordID = param.rateTimeOffNonbusyHoliday;

                //全价费率码
                this.QuanJia1RecordID = param.rateTimeFullBusyWorkday;
                this.QuanJia2RecordID = param.rateTimeFullBusyWeekend;
                this.QuanJia3RecordID = param.rateTimeFullBusyHoliday;
                
                //车票验证指示
                if (param.reusable > 0)
                {
                    this.Reusable = true;
                }
                else
                {
                    this.Reusable = false;
                }

                if (param.lightOn == 0)
                {
                    this.LightOn = false;
                }
                else
                {
                    this.LightOn = true;
                }

                if (param.beepOn == 0)
                {
                    this.BeepOn = false;
                }
                else
                {
                    this.BeepOn = true;
                }

                if (param.awardIndustryBus == 0)
                {
                    this.AwardIndustryBus = false;
                }
                else
                {
                    this.AwardIndustryBus = true;
                }

                if (param.ticketPriceAward == 0)
                {
                    this.TicketPriceAward = false;
                }
                else
                {
                    this.TicketPriceAward = true;
                }

                if (param.checkGiveStatn == 0)
                {
                    this.CheckGiveStatn = false;
                }
                else
                {
                    this.CheckGiveStatn = true;
                }

                if (param.verifyResv1 == 0)
                {
                    this.VerifyResv1 = false;
                }
                else
                {
                    this.VerifyResv1 = true;
                }

                if (param.accmTakeAward == 1)//累计乘坐
                {
                    this.IsCheckedLJCZ = true;
                }
                else
                {
                    this.IsCheckedLJCZ = false;
                }
                if (param.comboAward == 1)//联乘
                {
                    this.IsCheckedLC = true;
                }
                else
                {
                    this.IsCheckedLC = false;
                }
                if (param.verifyResv2 == 0)
                {
                    this.VerifyResv2_BiLi = true;
                    this.VerifyResv2_DingZhi = false;
                }
                else
                {
                    this.VerifyResv2_DingZhi = true;
                    this.VerifyResv2_BiLi = false;
                }

                if (param.awardIndustryShip == 0)
                {
                    this.AwardIndustryShip = false;
                }
                else
                {
                    this.AwardIndustryShip = true;
                }

                if (param.ctrlCanfill == 1)
                {
                    this.CtrlCanfill = true;
                }
                else
                {
                    this.CtrlCanfill = false;
                }

                if (param.ctrlJSTP == 1)
                {
                    this.CtrlJSTP = true;
                }
                else
                {
                    this.CtrlJSTP = false;
                }

                if (param.ctrlCantouzhi == 1)
                {
                    this.CtrlCanTouzhi = true;//不允许透支
                }
                else
                {
                    this.CtrlCanTouzhi = false;
                }

                if (param.ctrlCansale == 1)
                {
                    this.CtrlCansale = true;
                }
                else
                {
                    this.CtrlCansale = false;
                }

                if (param.ctrlReward == 1)
                {
                    this.CtrlReward = true;
                }
                else
                {
                    this.CtrlReward = false;
                }

                if (param.ctrlResv5 == 1)
                {
                    this.CtrlResv5 = true;
                }
                else
                {
                    this.CtrlResv5 = false;
                }

                if (param.accmAwardWay == 0)
                {
                    this.AccmAwardWayTime = true;
                    this.AccmAwardWayAmt = false;
                }
                else
                {
                    this.AccmAwardWayTime = false;
                    this.AccmAwardWayAmt = true;
                }


                if (param.awardPriority == 0)
                {
                    this.AwardPriority00 = true;//重复优惠
                    this.AwardPriority01 = false;
                    this.AwardPriority02 = false;
                    this.AwardPriority03 = false;
                    this.AwardPriority04 = false;
                    this.AwardPriority05 = false;
                }
                else if (param.awardPriority == 1)
                {
                    this.AwardPriority00 = false;
                    this.AwardPriority01 = true;//联乘=累积>轨道交通时间优惠
                    this.AwardPriority02 = false;
                    this.AwardPriority03 = false;
                    this.AwardPriority04 = false;
                    this.AwardPriority05 = false;
                }
                else if (param.awardPriority == 2)
                {
                    this.AwardPriority00 = false;
                    this.AwardPriority01 = false;
                    this.AwardPriority02 = true;//联乘>累积>轨道交通时间优惠
                    this.AwardPriority03 = false;
                    this.AwardPriority04 = false;
                    this.AwardPriority05 = false;
                }
                else if (param.awardPriority == 3)
                {
                    this.AwardPriority00 = false;
                    this.AwardPriority01 = false;
                    this.AwardPriority02 = false;
                    this.AwardPriority03 = true;//累积>联乘>轨道交通时间优惠
                    this.AwardPriority04 = false;
                    this.AwardPriority05 = false;
                }
                else if (param.awardPriority == 4)
                {
                    this.AwardPriority00 = false;
                    this.AwardPriority01 = false;
                    this.AwardPriority02 = false;
                    this.AwardPriority03 = false;
                    this.AwardPriority04 = true;//轨道交通时间优惠=(联乘>累积)
                    this.AwardPriority05 = false;
                }
                else if (param.awardPriority == 5)
                {
                    this.AwardPriority00 = false;
                    this.AwardPriority01 = false;
                    this.AwardPriority02 = false;
                    this.AwardPriority03 = false;
                    this.AwardPriority04 = false;
                    this.AwardPriority05 = true;//轨道交通时间优惠=(累积>联乘)
                }

                if (param.lastReward == 1)//若为1则取消最后乘次奖励
                {
                    this.LastReward = true;
                }
                else
                {
                    this.LastReward = false;
                }
            }
            
        }


        private ObservableCollection<ColorDefine> SetColorDefine()
        {
            ObservableCollection<ColorDefine> colors = new ObservableCollection<ColorDefine>();
            ColorDefine obj1 = new ColorDefine();
            obj1.Color = "无色";
            obj1.ColorValue = 0;
            ColorDefine obj2 = new ColorDefine();
            obj2.Color = "蓝色";
            obj2.ColorValue = 1;
            ColorDefine obj3 = new ColorDefine();
            obj3.Color = "红色";
            obj3.ColorValue = 2;
            ColorDefine obj4 = new ColorDefine();
            obj4.Color = "粉色";
            obj4.ColorValue = 3;
            ColorDefine obj5 = new ColorDefine();
            obj5.Color = "绿色";
            obj5.ColorValue = 4;
            ColorDefine obj6 = new ColorDefine();
            obj6.Color = "浅绿色";
            obj6.ColorValue = 5;
            ColorDefine obj7 = new ColorDefine();
            obj7.Color = "黄色";
            obj7.ColorValue = 6;
            ColorDefine obj8 = new ColorDefine();
            obj8.Color = "白色";
            obj8.ColorValue = 7;
            ColorDefine objnondef = new ColorDefine();
            objnondef.Color = "未定义";
            objnondef.ColorValue = 255;
            colors.Add(obj1);
            colors.Add(obj2);
            colors.Add(obj3);
            colors.Add(obj4);
            colors.Add(obj5);
            colors.Add(obj6);
            colors.Add(obj7);
            colors.Add(obj8);
            colors.Add(objnondef);
            return colors;
        }
    }
}
